#include "StdAfx.h"
#include "OgreRenderFrameListener.h"

OgreRenderFrameListener::OgreRenderFrameListener(void)
: m_pAni(NULL), m_aniSpeed(1.0f)
{
}

OgreRenderFrameListener::~OgreRenderFrameListener(void)
{
}

bool OgreRenderFrameListener::frameStarted(const Ogre::FrameEvent& evt)
{
	if(m_pAni)
		m_pAni->addTime(evt.timeSinceLastFrame * m_aniSpeed);
	return true;
}

void OgreRenderFrameListener::setAnimationState( Ogre::AnimationState* pAni, Ogre::Real speed /*= 1.0f*/ )
{
	if(m_pAni)
	{
		m_pAni->setEnabled(false);
		m_pAni->setTimePosition(0.0f);
	}
	if(pAni)
	{
		m_pAni = pAni;
		m_aniSpeed = speed;
		pAni->setEnabled(true);
	}
	
}
